using UnityEngine;

namespace ai_library
{
	public class EntityFactoryException : System.Exception
	{
		protected string message;
		public EntityFactoryException(string message) { this.message = message; }
		public override string Message { get { return message; } }
		public override string ToString() { return "Agent Factory Exception: " + message; }
	}

	public static class EntityFactory
	{
		private const float Mass = 3.0f;
		private const float MaxSpeed = 5.0f;
		private const float MaxForce = 5.0f;
		private const float MaxTurnRate = 2.0f;
		private const float BRadius = 2.0f;
		private static readonly Vector2 Velocity = Vector2.zero;

		//todo: consider abstract factory

		public static IEntity Get(EntityTypes entityTypes, Transform transform)
		{
			IEntity retAgent = null;

			switch (entityTypes)
			{
			case EntityTypes.Agent:
				retAgent = new Agent(transform, Velocity, Mass, MaxSpeed, MaxForce, MaxTurnRate, BRadius);
				break;

			case EntityTypes.Obstacle:
				retAgent = new Obstacle(transform);
				break;
			}

			if (retAgent == null)
				throw new EntityFactoryException("AgentType " + entityTypes + " not defined in factory");

			return retAgent;
		}
	}
}

